/*
    This file is part of Slydini.

    Slydini is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Slydini is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Slydini.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <cv.h>
#include <highgui.h>
#include <stdio.h>
#include <ctype.h>

#include <QApplication>
#include <QtGui>

#define WINW 320
#define WINH 240

#include "processor.h"
#include "gui/left_menu.h"
#include "gui/up_menu.h"
#include "gui/down_menu.h"
#include "gui/right_menu.h"

int main(int argc, char** argv) {
	// GUI
	Configuration *c = Configuration::getConfiguration("configuration.xml");
	QApplication app(argc, argv);
	QWidget *window = new QWidget;
	QWidget *d = QApplication::desktop();
	window->setGeometry((d->width()-c->queryInt("desktop/width"))/2,(d->height()-c->queryInt("desktop/height"))/2,c->queryInt("desktop/width"),c->queryInt("desktop/height"));
	window->setWindowTitle("Slydini");
	window->setFixedSize(c->queryInt("desktop/width"),c->queryInt("desktop/height"));
	QIcon *icon = new QIcon("slydini.png");
	window->setWindowIcon(*icon);
	Processor processor(window);
	processor.setGeometry(0,0,c->queryInt("desktop/width"),c->queryInt("desktop/height"));
/*
	LeftMenu *lmenu = new LeftMenu();
	lmenu->show();
    DownMenu *dmenu= new DownMenu();
    dmenu->show();     
    UpMenu *umenu= new UpMenu();
    umenu->show();     
    RightMenu *rmenu= new RightMenu();
    rmenu->show();
*/	
	processor.grabKeyboard();
	QObject::connect(&processor, SIGNAL(quit()), &app, SLOT(quit()));
	int ret = processor.initialize(argc,argv);
	if (ret)
			return ret;

//	QPushButton quit(QString::fromUtf8("Wyjście"),window);
//	quit.setGeometry(360,10,100,30);

//	QPushButton showSkin(QString::fromUtf8("Pokaż skórę"),window);
//	showSkin.setGeometry(360,135,100,30);

	window->show();

	QTimer *timer = new QTimer();
	QObject::connect(timer, SIGNAL(timeout()), &processor, SLOT(processFrame()));
	timer->start(0);

	return app.exec();
}

